<template>
  <div>
    <div class="help-head">
      <h2>实名认证</h2>
      <p>为配合国家监管要求，请完成实名认证</p>
    </div>
    <div class="process-main">
      <div class="login-form">
        <div class="login-form-cont">
          <van-form>
            <van-cell-group class="cell-item" title="真实姓名">
              <van-field
                class="login-form-item"
                clearable
                v-model="formData.realseName"
                ref="realseName"
                placeholder="请输入您的真实姓名"
              >
              </van-field>
            </van-cell-group>

            <van-cell-group class="cell-item" title="身份证号">
              <van-field
                class="login-form-item"
                clearable
                v-model="formData.idCard"
                ref="idCard"
                placeholder="请输入您的身份证号码"
              >
              </van-field>
            </van-cell-group>
            <!--    <van-checkbox
              class="checkbox"
              v-model="checked"
              checked-color="#07c160"
            >
              <template #icon
                ><img
                  class="checked-icon"
                  src="@/assets/images/ic_login_cb_uns.png"
              /></template>
              <template #default>
                <h3>我已经阅读并同意<span>《用户注册服务协议》</span></h3>
              </template>
            </van-checkbox> -->
            <van-button
              @click="onSubmit"
              class="login-btn"
              round
              block
              type="info"
              color="linear-gradient(to right, #ebb15b, #f6c775)"
            >
              下一步
            </van-button>
          </van-form>
        </div>
      </div>
    </div>
    <van-popup class="open-vip-ing" close-icon="close" round v-model="vipIng">
      <div class="open-vip-ing-main" @click="$utils.push('/process')">
        <div class="o-b">
          <span @click="$router.go(-1)"></span>
          <span @click="vipIng=false"></span>
        </div></div
    ></van-popup>
  </div>
</template>

<script>
import { authIdentity } from '@/api/user'

export default {
  data() {
    return {
      activeNames: ['1'],
      formData: {
        realseName: undefined,
        idCard: undefined
      },
      vipIng: false
    }
  },
  mounted() {
    this.$utils.inBroBack(this.goBack)
  },

  destroyed() {
    this.$utils.unFunction(this.goBack)
  },
  methods: {
    goBack() {
      this.vipIng = true
    },
    onSubmit() {
      if (!this.formData.realseName) {
        this.$toast({
          position: 'bottom',
          message: '请输入您的真实姓名'
        })
        this.$refs.realseName.focus()
        return
      }
      if (!this.formData.idCard) {
        this.$toast({
          position: 'bottom',
          message: '请输入您的身份证号码'
        })
        this.$refs.idCard.focus()
        return
      }
      authIdentity(this.formData).then(async res => {
        if (res.status == 1) {
          this.$utils.replace('/process/bank')
        }
      })
    }
  }
}
</script>

<style lang="less" scoped>
.open-vip-ing {
  height: 62vh;
  background: url('../../assets/images/ic_dialog_back.png') no-repeat;
  background-size: 100% 100%;
  .open-vip-ing-main {
    width: 350px;
    margin: 0 auto;
    margin-top: 50vh;
    text-align: center;
    color: #333;
    overflow: hidden;
    position: relative;
    h2 {
      font-size: 20px;
      font-weight: bold;
      margin-top: 20px;
    }
    p {
      margin-top: 14px;
      font-weight: bold;
      font-size: 16px;
    }
    .o-b {
      color: #fff;
      margin-top: 20px;
      span {
        display: inline-block;
        width: 50%;
        padding: 20px 0;
      }
    }
  }
}
::v-deep .van-hairline--top-bottom::after,
.van-hairline-unset--top-bottom::after {
  border-width: 0;
}
.help-head {
  background: #444444;
  padding: 30px 20px 40px 20px;
  h2 {
    font-size: 18px;
    color: #fff;
    margin-bottom: 10px;
  }
  p {
    font-size: 14px;
    color: #fff;
  }
}
.login-form {
  background: #fff;
  padding-top: 40px;
  border-radius: 40px 40px 0 0;
  position: relative;
  top: -24px;
  .login-form-cont {
    width: 346px;
    margin: 0 auto;
    .cell-item {
      border-bottom: 1px solid #eee;
      margin-bottom: 20px;
    }
    h2 {
      padding: 10px 16px;
      font-size: 26px;
      font-weight: 600;
      color: #3e4a59;
      margin-bottom: 20px;
    }
    .login-form-item {
      &.code-input {
        ::v-deep .van-field__body {
          width: 90%;
        }
      }
      .tel-icon {
        width: 20px;
        height: 20px;
      }
      .get-code {
        position: relative;
        border: none;
        background: none;
        width: auto;
        height: auto;
        color: #b9c2cd;
        &::before {
          left: -10px;
          top: 50%;
          transform: translate(0, -50%);
          position: absolute;
          content: '';
          display: inline-block;
          width: 1px;
          height: 10px;
          background: #b9c2cd;
        }
      }
    }
    .checkbox {
      padding: 10px 16px;
      display: flex;
      align-items: center;
      .checked-icon {
        width: 14px;
        height: 14px;
      }
      h3 {
        font-size: 12px;
        span {
          font-size: 12px;
          color: #f4c370;
        }
      }
    }
  }
  .login-btn {
    width: 220px;
    margin: 0 auto;
    margin-top: 50px;
  }
}
</style>
